# 作者: Isearph
# 创建日期: 2025年6月13日
# 作者邮箱: 2665497226@qq.com


import cv2


solarterms = ["立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
        "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降",
        "立冬", "小雪", "大雪", "冬至", "小寒", "大寒"]

Month_CH = ['雨月', '风月', '芽月', '花月', '牧月', '获月',
            '热月', '菓月', '酿月', '雾月', '霜月', '雪月']

JapMonths = ['睦月', '如月', '弥生', '卯月', '皋月', '水无月',
             '文月', '叶月', '长月', '神无月', '霜月', '师走']

# img = cv2.imread(r'images\jap_monthes.jpg')

jap_monthes_images = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

# for i in range(3):
#     for j in range(4):
#         index = i * 4 + j
#         jap_monthes_images[i*4+j] = img[i*124:(i+1)*124, j*128:(j+1)*128]
#         x, y = jap_monthes_images[i*4+j].shape[0:2]
#         jap_monthes_images[i*4+j] = cv2.resize(jap_monthes_images[i*4+j], (int(y / 1.164), int(x / 1.164)))
#         filename = os.path.join('images', f"{JapMonths[index]}.jpg")
#
#         # 用 imencode 写入支持中文路径的文件
#         success, encoded_image = cv2.imencode('.jpg', jap_monthes_images[i*4+j])
#         if success:
#             with open(filename, mode='wb') as f:
#                 f.write(encoded_image.tobytes())


# def imread_unicode(path):
#     stream = np.fromfile(path, dtype=np.uint8)
#     return cv2.imdecode(stream, cv2.IMREAD_COLOR)
#
#
# for i in range(12):
#     img_path = os.path.join('images', f'f{i}.jpg')
#     print(f'Processing: {img_path}')
#
#     img = cv2.imread(img_path)
#     print(img.shape)
#     img = img[30:390, 22:300]
#     x, y = img.shape[0:2]
#     img = cv2.resize(img, (int(y/2.527), int(x/2.527)))
#
#     save_path = os.path.join('images', f'f{i}a.jpg')
#     cv2.imencode('.jpg', img)[1].tofile(save_path)


img_path = r'images/thunderstorm.jpg'
print(f'Processing: {img_path}')

img = cv2.imread(img_path)
print(img.shape)
x, y = img.shape[0:2]
img = cv2.resize(img, (int(y/2.5), int(x/2.5)))

cv2.imencode('.jpg', img)[1].tofile(img_path)
